package com.daojia.daojiasync.controller;

import com.daojia.daojiasync.service.WorkOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/workorders")
public class WorkOrderController {
    
    @Autowired
    private WorkOrderService workOrderService;
    
    @PostMapping("/sync")
    public String syncWorkOrders(@RequestParam String startTime, 
                               @RequestParam String endTime) {
        try {
            workOrderService.syncWorkOrders();
            return "同步完成";
        } catch (Exception e) {
            return "同步失败: " + e.getMessage();
        }
    }
}